package com.sinosoft.bee.services.proposal.service.impl;

import com.sinosoft.bee.services.proposal.entity.proposal.ProposalMain;
import com.sinosoft.bee.services.proposal.service.ProposalMainService;
import com.sinosoft.bee.services.proposal.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @Author: TrickerL
 * @Description: bee
 * @Date: Create in 15:33 2018/5/16
 * @Modified By:
 */
@Service
@Transactional
public class ProposalMainServiceImpl implements ProposalMainService {

    @Autowired
    private ProposalMainMapper proposalMainMapper;

    private String proposalID;
    /**
     * 新增建议书信息
     * @param proposalMain
     * @return
     */
    @Override
    public Integer insertProposalMainInfo(ProposalMain proposalMain){
        return proposalMainMapper.insertProposalMain(proposalMain);
    }

    public void insertProposalMainPart(ProposalMain proposalMain){
        proposalMainMapper.insertProposalMainPart(proposalMain);
    }

    /**
     * 删除建议书
     * @param proposalMain
     * @return
     */
    @Override
    public Integer deleteProposalMain(ProposalMain proposalMain){
        return proposalMainMapper.deleteProposalMain(proposalMain);
    }

    /**
     * 查询建议书
     * @return
     */
    @Override
    public List<ProposalMain> selectAllMain(){
        return proposalMainMapper.selectAllMain();
    }

    /**
     * 修改建议书通过建议书ID
     * @param proposalMain
     */
    @Override
    public void  updateById(ProposalMain proposalMain){
        proposalMainMapper.UpdateById(proposalMain);
    }



    @Override
    /**
     * 生成建议书
     * 1.生成建议书号
     * 2.从其他系统里获取人员信息
     * 3.设置 操作五要素
     */
    public void createProposal(){
        ProposalMain proposalMain=new ProposalMain();
        proposalID=UUID.randomUUID().toString();
        proposalMain.setProposalId(proposalID);
        proposalMain.setGmtCreate(new Date());
        proposalMain.setGmtModified(new Date());

    }
}
